var app = getApp();

Page({
  data: {
  },
  onLoad: function() {
    
  },
  onShow: function() {
    var that = this;
    var url = getCurrentPages()[0].route;
    var userInfo = app.globalData.userInfo;
    if (userInfo == null) {
        wx.showModal({
        title: '提示',
        content: '该操作需要登录，是否登录？',
        success(res) {
          if (res.confirm) {
            wx.setStorage({
              key: 'lastpage',
              data: url,
            })
            wx.redirectTo({
              url: '/pages/wode/login/login',
            })
          } else {
            wx.switchTab({
              url: '/pages/home/index',
            })
          }
        }
      })
    } else {
      this.setData({
        userInfo: userInfo,
      })
    }
  },
  openAd: function() {
     wx.showToast({
      title: '暂无更多好玩的哦，敬请期待~',
      icon:'none'
    })
    let appbox = qq.createAppBox({
      adUnitId: "be9d2747455d22566ad13e169013c68c"
    })
    appbox.load().then(() => {
      appbox.show()
    })
  },
  exit: function() {
    wx.showModal({
      title: '提示',
      content: '是否确定退出登录？',
      success(res) {
        if (res.confirm) {
          app.globalData.userInfo = null;
          wx.clearStorage();
          var url = getCurrentPages()[0].route;
          wx.setStorage({
            key: 'lastpage',
            data: url,
          })
          wx.redirectTo({
            url: '/pages/wode/login/login',
          })
        }
      }
    })
  },
  mypublish:function(){
   wx.navigateTo({
     url: '/pages/wode/mypublish/mypublish',
   })
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return {
      title: "拼车信息免费发，快来戳我吧~",
      path: '/pages/home/index',
      imageUrl: '../../image/share.jpg'
    }
  },
})